﻿/*****************************************************************//**
 * \file   SurgicalRobotCommon.h
 * \brief  通用数据结构及宏定义
 *
 * \author Administrator
 * \date   July 2021
 * \modify by Administrator
 * \date   July 2021

 *********************************************************************/
#pragma once

#include "Eigen/Dense"
#include "../hardware_interface/Robot/RobotControlInterface.h"
#include "../hardware_interface/HapticDevice/HapticDeviceControl.h"
#include <QImage>
#include <pthread.h>
#include <sched.h>
#include <unistd.h>

#include <semaphore.h>
 //定义手术机器人系统物理参数类
#define M_PI 3.14159265358979323846
#define PI (3.1415926535897932346f)

#define NOARM			0  
#define ARMTYPE_AOBOi5	1
#define ARMTYPE_UR3		2
#define ARMTYPE_FRANKA	3
#define NOTOOL			0   
#define TOOLTYPE_CAMERA	1    
#define TOOLTYPE_BoplarHook	2
#define TOOLTYPE_4DOF	3 
#define TOOLTYPE_3DOF	4
#define TOOLTYPE_TRANDITION	4
#define HAPTICTYPE_LEFT 0
#define HAPTICTYPE_RIGHT 1

#define RobotArm0      0
#define RobotArm1      1 
#define RobotArm2      2
#define RobotArm3      3
#define MaxRobotNum    4

#define Robot0NetPort  8899

#define DEBUG_ROBOT_READ  0
#define DEBUG_HAPTIC_CONTROL_ROBOT 0
#define DEBUG_CAMERA_READ 0

#define EXPERMENTAL_VAL            1 //1:base, 2 fangjin, 3 xiaoxilin

#define EXPERMENTAL_BASE           1 //base


extern sem_t hHapticreadSemaphore;
extern sem_t hHapticSemaphore;
extern sem_t hHapticControlRobotSemaphore;
extern sem_t hReadRobotDataSemaphore;
extern sem_t hCutfusion;
extern sem_t hHapticForceFeedback;

extern QImage qComImage;
//机械臂的ip、端口等配置参数
struct SRobotConfig
{
	char cRobotArmIP[256];//机械臂连接IP
	char cRobotArmGW[256];//机械臂连接端口号
	char cRobotArmMA[256];//机械臂连接网关
	int iRobotarmType;    //机械臂类型
	int iRobotToolType;   //机械臂所持手术器械类型
	char cCoordinateSystem[128];
	double dRCMPosition[3];//RCM点在全局坐标系下的x,y,z
	int iMotornumber[5];
};
enum class enumRobotName :int {
	eRobot1 = 0,
	eRobot2 = 1,
	eRobot3 = 2,
	eRobot4 = 3
};

enum class eRobotEndToolName :char {
	eCamera,
	eBoplarHook,
	eFourDofApparatus,
	eThreeDofApparatus
};

//机械臂配置数据
extern SRobotConfig sRobotConfigPara[MaxRobotNum];
//机械臂实时数据
extern SRobotRealTimeData sRobotRunData[MaxRobotNum];
//主手力控设备数据
extern SRobotHapticDeviceData sHapticRunData[2];//左右手2个

extern unsigned int iCamera;
extern unsigned int iGet;
extern unsigned int iSurgical;
extern unsigned int iControl;
extern unsigned int iReader;
